home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-01 / snip0493.zip / FERRORF.C < prev    next >
C/C++ Source or Header  |  1993-04-05  |  687b  |  26 lines

  1. /*  FERRORF.C
  2. **  Prints error message with printf() formatting syntax, then a colon,
  3. **  then a message corressponding to the value of errno, then a newline.
  4. **  Output is to filehandle.
  5. **
  6. **  Public Domain by Mark R. Devlin, free usage is permitted.
  7. */
  8.  
  9. #include <stdio.h>
  10. #include <stdlib.h>
  11. #include <stdarg.h>
  12. #include <string.h>
  13.  
  14. int ferrorf(FILE *filehandle, const char *format, ...)
  15. {
  16.     int vfp, fp;
  17.     va_list vargs;
  18.  
  19.     vfp = fp = 0;
  20.     va_start(vargs, format);
  21.     vfp = vfprintf(filehandle, format, vargs);
  22.     va_end(vargs);
  23.     fp = fprintf(filehandle, ": %s\n", sys_errlist[errno]);
  24.     return ((vfp==EOF || fp==EOF) ? EOF : (vfp+fp));
  25. }
  26.